package com.jh.microservice.base;

import org.springframework.context.PayloadApplicationEvent;
import org.springframework.context.event.ApplicationEventMulticaster;
import org.springframework.context.event.SimpleApplicationEventMulticaster;

public class ApplicationEventMulticasterDemo {
    public static void main(String[] args) {
        ApplicationEventMulticaster multicaster = new SimpleApplicationEventMulticaster();
        multicaster.addApplicationListener(event -> {
            System.out.println("事件：" + event.getSource());
        });
        multicaster.multicastEvent(new PayloadApplicationEvent<Object>("1", "Hello World 1"));
        multicaster.multicastEvent(new PayloadApplicationEvent<Object>("2", "Hello World 2"));
    }
}
